<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>员工申请</title>
    <link href="/res/css/respective/order/back-order.css" rel="stylesheet">
    <link href="/res/third/dropdown/dropdownlist.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        .back-main a {
            text-decoration: none !important;
        }
		.layui-layer-title{
			font-weight: bold;
		}
        .blueBtn {
            display: inline-block;
            height: 32px;
            line-height: 32px;
            margin: 3px 0;
            text-align: center;
            color: #fff;
            background: #00b1db;
            border-radius: 3px;
            cursor: pointer;
            padding: 0 10px;
        }

        .grayBtn {
            display: inline-block;
            height: 32px;
            line-height: 32px;
            margin: 3px 0;
            text-align: center;
            color: #fff;
            background: gray;
            border-radius: 3px;
            cursor: pointer;
            padding: 0 10px;
        }
        
        .mainhead1{width: 100%;height: 40px;display: inline-block;}
		.mainhead_one{display: inline-block;height: 40px;float: left;width: 10%;text-align: center;line-height: 40px;font-weight: bold;color:#30D5F7;border-top: 2px solid #30D5F7;}
		.mainhead_two{display: inline-block;height: 40px;float: left;width: 10%;text-align: center;line-height: 40px;font-weight: bold;cursor: pointer;border-left: 1px solid #ddd;border-bottom: 1px solid #ddd;}
		.mainhead_three{display: inline-block;height: 40px;float: left;border-bottom: 1px solid #ddd;width:80%}
		.maincontext{display: inline-block;width: 100%;}
		.fchild{display: inline-block;float: right;}
		.fyjt{color:#b2b2b2;background-color: #FBFBFB;border:1px solid #ebebeb;padding: 0px 6px 0px 6px;margin: 18px 6px 0px 0px;cursor: pointer;}
		.warp .back-main .fyjt:hover {
			    color: #00ceff;
		}
		.warp.warp-supplier .back-main .fyjt:hover {
			    color: rgb(255, 192, 1);
		}
		.fygo{background-color: #09A8D2;color: #fff;padding: 1px 4px 1px 4px;margin: 20px 8px 0px 0px;cursor: pointer;font-size: 12px;}
		.fygo:hover{
			background-color: #00ceff;
		}
		.warp.warp-supplier .back-main .fygo{background-color: rgb(254, 169, 16);}
		.warp.warp-supplier .back-main .fygo:hover{
			background-color: rgb(255, 192, 1);
		}
		.fyin{margin-top: 18px;}
		.fyinput{border: none;height: 20px;width: 60px;border: 1px solid #ebebeb;}
		.fytext{font-size: 12px;margin: 21px 14px 0px 0px;}
		.addemp{display: inline-block;background-color:#09A8D2;color: #fff;height: 33px;width: 95px;text-align: center;font-weight: bold;line-height: 33px;border-radius:2px;margin-top: 17px;cursor: pointer;}
		 tr{height:45px;}
		 td{word-wrap:break-word;}
		 .thht{border-top: none!important;}
		 .layui-layer-title{font-weight: blod!important;font-size: 18px!important;}
		 .fenyediv{border-left: 1px solid #ddd;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;}
		 .agreeOrrefuse{cursor: pointer;color:#00ceff!important;}
		 .last_jj{width: 180px;display: inline-block;}
		 .font1,.font2{float: left;width: 90px;}
		 .pic1{width: 21px;height: 21px;display: inline-block;float: left;background-image: url("/res/images/oparaStatus/dapp.png");background-position: -44px -42px;margin-left: 57px;}
		 .pic2{width: 21px;height: 21px;display: inline-block;float: left;background-image: url("/res/images/oparaStatus/dapp.png");background-position: -29px -68px;margin-left: 57px;}
		 .font3,.font4{width: 50px;float: left;}
		 .refusefont{color:#E92500;}
		 .agreefont{color:#39A200;}
    </style>
</head>
<body>
<div class="warp">
[#include "/front/common/front_headAzt.html"]
    <div class="backcontent">
    [#include "/front/common/front_leftAzt.html"]
        <div class="back-main">
            <div class="inner cotentIner">
                <div class="title" id="bedoreEmp">员工管理</div>
                <div class="maincontext">
	                <div class="backTab" style="margin-bottom: 0px;">
	                    <ul>
	                        <li onclick="location.href='/employee/employee_list'">员工列表</li>
	                        <li class="on" style="margin-top: -2px;border-right: 1px solid #ddd;">员工审核
	                        	 [#if applyCount!=0]<span class="orange"><i></i>${applyCount!}</span>[/#if]
	                        </li>
	                    </ul>
	                </div>
	             	<table class="table" style="text-align: center;border-left: 1px solid #ddd;border-right: 1px solid #ddd;table-layout: fixed;">
			 			<thead>
						   	<tr style="background-color: #f8f8f8;"> 
								<th class="thht" width="15%">申请人账号</th>
								<th class="thht" width="15%">申请人姓名</th>
								<th class="thht" width="15%">申请人联系电话</th>
								<th class="thht" width="10%">所属角色</th>
								<th class="thht" width="23%">申请说明</th>
								<th class="thht" width="22%">操作</th>
							</tr>
						</thead>
						<tbody>
							<!--默认显示8行-->
							[#list pagination.list as user]
							<tr>
								<td>
									[#if user.email??]
										${user.email}
									[#else]
										[#if user.mobile??]
											${user.mobile}
										[/#if]
									[/#if]
								</td>
								<td>${user.realName!}</td>
								<td>${user.contactTel!}</td>
								<td>${user.roleName!}</td>
								<td>${user.applyReason!}</td>
								<td class="blackLink" style="width: 250px;text-align: center;">
									<div class="last_jj">
										[#if user.auditState=='0']
										<span class="font1"><a class="agreeOrrefuse" id="agreeApply" onclick="doagreeApply('${user.userId}','[#if user.email??]${user.email}[#else][#if user.mobile??]${user.mobile}[/#if][/#if]','${user.roleId!}')">同意</a></span>
										<span class="font2"><a class="agreeOrrefuse" onclick="refuseApply('${user.userId}','[#if user.email??]${user.email}[#else][#if user.mobile??]${user.mobile}[/#if][/#if]','${user.roleId!}')">拒绝</a></span>
										[/#if]
										[#if user.auditState=='1']
										<span class="pic1"></span>
										<span class="font3"><a class="agreefont">已同意</a></span>
										[/#if]
										[#if user.auditState=='2']
										<span class="pic2"></span>
										<span class="font4"><a class="refusefont">已拒绝</a></span>
										[/#if]
									</div>
								</td>
							</tr>
							[/#list]
						</tbody>
					</table>
					<div class="fenyediv" style="background: #F8F8F8;height: 60px;">
						 <div class="fchild fyjt" style="margin-right: 25px;" onclick="pageclick('empnext')">></div>
						 <div class="fchild fyjt" onclick="pageclick('emprev')"><</div>
						 <div class="fchild fygo" onclick="refempGO()">GO</div>
						 <div class="fchild fyin"><input class="fyinput"  type="text"></div>
						 <div class="fchild fytext" style="letter-spacing: 3px;"><span style="color: #FCB01C;">${pagination.pageNo!}</span>/${pagination.totalPage!}</div>
						 <div class="fchild fytext">共${pagination.totalCount!}条需求记录</div>
						 <input id="pageNo" type="hidden" value="${pagination.pageNo!}">
						 <input id="totalPage" type="hidden" value="${pagination.totalPage!}">
						 <input id="showType" type="hidden" value="2">
					</div>
				</div>
            </div>
        </div>
    </div>

[#include "/front/common/front_footerAzt.html"]
</div>

<script type="text/javascript" src="/res/js/common/jquery.1.9.1.min.js"></script>
<script type="text/javascript" src="/res/js/structure/struture.js"></script>
<script type="text/javascript" src="/res/js/common/common.js"></script>
<script type="text/javascript" src="/res/third/laydate/laydate.js"></script>
<script type="text/javascript" src="/res/third/layer/layer.js"></script>
<script type="text/javascript" src="/res/js/common/tppl.js"></script>
<script type="text/javascript" src="/res/third/nice-validator/jquery.validator.min.js?local=zh-CN"></script>
<script src="/res/third/dropdown/js/dropdownlist.js"></script>
<script type="text/javascript">
$(function(){
	$(".cotentIner").css('minHeight',$(window).height()-200);
});
function submitpage(pageNo,showType){
	 var layerIndex;
	 $.ajax({
          url: 'employee_page',
          data: {pageNo:pageNo,showType:showType},
          type: 'post',
		  beforeSend : function () {
			  	layerIndex = layer.load(1, {
				  shade: [0.1,'#fff'] //0.1透明度的白色背景
				});
          },
          success: function (data) {
             	if(data!=null){
             		$(".maincontext").remove();
             		$("#bedoreEmp").after(data);
             	}
          },
			complete : function() {
				layer.close(layerIndex);
			},
			error:function(xx){
				console.log(xx)
			}
      });
}
function pageclick(pagetype){
	 var pagetotal=parseInt($("#totalPage").val());
	 var pageNo=parseInt($("#pageNo").val());
	 var showType=$("#showType").val();
	 if(pagetype=='empnext'){
		 if(pageNo!=pagetotal){
			 pageNo=pageNo+1;
			 submitpage(pageNo,showType);
		 }
	 }
	 if(pagetype=='emprev'){
		 if(pageNo!=1){
			 pageNo=pageNo-1;
			 submitpage(pageNo,showType);
		 }
	 }
}
function refempGO(){
	 var pagetotal=parseInt($("#totalPage").val());
	 var pageNo=parseInt($(".fyinput").val());
	 var showType=$("#showType").val();
	 if(pageNo>=1&&pageNo<=pagetotal){
		 submitpage(pageNo,showType);
	 }
}
var agreeLayerindex;
function refuseApply(uid,login,roleId){
	var layerIndex;
	$.ajax({
        url : 'showAgreeApplyView',
        type : 'post',
        data:{uid:uid,login:login,roleId:roleId,totype:1},
		beforeSend : function () {
				layerIndex = layer.load(1, {
				  shade: [0.1,'#fff'] //0.1透明度的白色背景
				});
        },
        success : function(data) {
        	layer.open({
				  btn:1,
				  area:['450px','350px'],
				  title: '拒绝申请',
				  content: data,
				  success: function(layero, index){
					  agreeLayerindex=index;
				  }
			});   
        },
		complete : function() {
			layer.close(layerIndex);
		}
   })
}
function doagreeuser(uid,login,roleId){
	var layerIndex;
	$.ajax({
        url : 'showAgreeApplyView',
        type : 'post',
        data:{uid:uid,login:login,roleId:roleId,totype:2},
        beforeSend : function () {
		  	layerIndex = layer.load(1, {
			  shade: [0.1,'#fff'] //0.1透明度的白色背景
			});
        },
        success : function(data) {
        	layer.open({
				  btn:1,
				  area:['500px','320px'],
				  title: '同意申请',
				  content: data,
				  success: function(layero, index){
					  agreeLayerindex=index;
				  }
			});   
        },
        complete : function() {
			layer.close(layerIndex);
		}
   })

}

var pid='[#if pid??]${pid}[/#if]';
function doagreeApply(uid,login,roleId){
	var layerIndex;
	if(pid==''){
		doagreeuser(uid,login,roleId);
	}else{
		$.ajax({
            url : 'queryRoleByCompanyId',
            type : 'post',
            data:{requestType:1},
            dataType : 'json',
			  beforeSend : function () {
				  	layerIndex = layer.load(1, {
					  shade: [0.1,'#fff'] //0.1透明度的白色背景
					});
            },
            success : function(data) {
                if(data.success){
                	doagreeuser(uid,login,roleId);
                }else{
                	layer.open({
       					  btn:0,
       					  title: '提醒',
       					  content: "<div style='width:300px;height:120px;margin-top:30px;'>"
       					  				+"<div style='padding-left:20px;padding-right:20px;text-align:center;'>"
       					  					+"<span style='display:inline-block;float:left;'>"+data.msg+"</span>"
       					  				    +"<span class='addemp' onclick='location.href="+'"/orgstruct/addrole"'+"'>去创建</span>"
       					  				+"</div>"
       					  		  +"</div>",
       					  success: function(layero, index){
       						  $(layero).find(".layui-layer-title").remove();
       					  }
  					});

                }
            },
			  complete : function() {
				layer.close(layerIndex);
			}
       })
	}
}
</script>
</body>
</html>